package com.after.saas.system.controller;


import com.after.saas.common.constants.Result;
import com.after.saas.common.model.dto.OperatorLogDTO;
import com.after.saas.common.utils.ResponseUtil;

import com.after.saas.system.model.OperatorLog;
import com.after.saas.system.service.OperatorLogService;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import java.util.Set;

/**
 * <p>
 * 操作日志记录 前端控制器
 * </p>
 *
 * @author hjchen
 * @since 2021-07-17
 */
@RestController
@RequestMapping("/operator-log")
public class OperatorLogController {

    @Autowired
    private OperatorLogService logService;

    @PostMapping
    public Result save(@RequestBody OperatorLogDTO logDTO) {
        OperatorLog operatorLog = new OperatorLog();
        BeanUtils.copyProperties(logDTO, operatorLog);
        logService.save(operatorLog);
        return ResponseUtil.SUCCESS();
    }


    @PostMapping(value = "/listByIds")
    public Result listByIds(@RequestBody Set<String> ids) {
        return ResponseUtil.SUCCESS(logService.getByIds(ids));
    }
}
